/**
 * @(#)ApkConfigController.java 2016年12月1日
 * Copyright(C) 2016 ZHEXIN IT CO.,LTD. All rights reserved.
 */
package org.jsbd.boss.action;

import java.util.Map;

import javax.annotation.Resource;

import org.apache.commons.lang.StringUtils;
import org.jsbd.boss.common.DataGridModel;
import org.jsbd.boss.domian.TaskRateVO;
import org.jsbd.boss.service.ITaskRateService;
import org.jsbd.boss.util.DateUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 新增留存任务
 * 
 * @author <a href="mailto:wangjunbiao@zhexinit.com" >王俊标</a>
 * @version 1.0.0
 */
@Controller
@RequestMapping("/taskRate")
public class TaskRateController {
	public static final Logger LOGGER = LoggerFactory.getLogger(TaskRateController.class);

	@Resource
	private ITaskRateService taskRateService;

	@RequestMapping(value = "/list", method = RequestMethod.GET)
	public String list(Model model) {
		return "/taskRate/list";
	}

	@RequestMapping(value = "/listJson", method = RequestMethod.POST)
	@ResponseBody
	public Map<String, Object> listJson(DataGridModel page, TaskRateVO tsVO) {
		String startTime = tsVO.getStartTime();
		String endTime = tsVO.getEndTime();
		if (StringUtils.isBlank(startTime) && StringUtils.isBlank(endTime)) {
			tsVO.setStartTime(DateUtil.getCurrentDateStr());
		}
		if (!StringUtils.isBlank(startTime)) {
			startTime = startTime.replace("-", "");
			tsVO.setStartTime(startTime);
		}
		if (!StringUtils.isBlank(endTime)) {
			endTime = endTime.replace("-", "");
			tsVO.setEndTime(endTime);
		}
		return taskRateService.getListWithPage(page, tsVO);
	}

}
